import 'package:flutter/material.dart';
import 'package:mall/screens/order/order_list_page.dart';
import 'package:mall/theme.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 订单参数
class OrderPageArgs {
  final int storeId;
  final int index;

  OrderPageArgs(this.storeId, this.index);
}

/// 订单tab页面
class OrderPage extends StatelessWidget {
  static const routeName = '/OrderPage';
  final OrderPageArgs args;
  final List<String> tabLabels = <String>['全部订单', '待付款', '待发货', '待收货'];

  OrderPage({
    Key key,
    @required this.args,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(args.storeId == null ? '我的订单' : '店铺订单'),
      ),
      body: DefaultTabController(
        length: tabLabels.length,
        initialIndex: args.index,
        child: Column(
          children: [
            SizedBox(
              height: 30.w,
              child: TabBar(
                tabs: List.generate(
                  tabLabels.length,
                  (index) => Tab(text: tabLabels[index]),
                ),
                indicatorSize: TabBarIndicatorSize.label,
                labelColor: Theme.of(context).primaryColor,
                unselectedLabelColor: kTextColor,
              ),
            ),
            Expanded(
              child: TabBarView(
                children: List.generate(
                  tabLabels.length,
                  (index) => OrderListPage(storeId: args.storeId, index: index),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
